const formatMarkdown = {
    done: />> +(.*)/g,
    error: /<< +(.*)/g,
    going: /-> +(.*)/g,
    doubt: /\?\? +(.*)/g,
    block: /> +(.*)/g,
    format(str) {
        return this.jsonParse(JSON.parse(str))
    },
    jsonParse(str) {
        str = str
            .replace(this.done, "<div class='done todoBox'><span id='done' uuid='" + getCode() + "' class='iconfont icon-chenggong1'></span>" + "$1" + "</div>")
            .replace(this.error, "<div class='error todoBox'><span id='error' uuid='" + getCode() + "' class='iconfont icon-shibai'></span>" + "$1" + "</div>")
            .replace(this.going, "<div class='going todoBox'><span id='going' uuid='" + getCode() + "' class='iconfont icon-c'></span>" + "$1" + "</div>")
            .replace(this.doubt, "<div class='doubt todoBox'><span id='doubt' uuid='" + getCode() + "' class='iconfont icon-bangzhu'></span>" + "$1" + "</div>")
            .replace(this.block, "<div class='block'>" + "$1" + "</div>")
        return str
    }
}
function getRandom(min, max) {
    return Math.round(Math.random() * (max - min) + min);
}

function getCode() {
    let code = '';
    for (var i = 0; i < 6; i++) {
        var type = getRandom(1, 3);
        switch (type) {
            case 1:
                code += String.fromCharCode(getRandom(48, 57));//数字
                break;
            case 2:
                code += String.fromCharCode(getRandom(65, 90));//大写字母
                break;
            case 3:
                code += String.fromCharCode(getRandom(97, 122));//小写字母
                break;
        }
    }
    return code;
}
export default formatMarkdown